//
//  JYTHttpClient.h
//  JYT_IOS
//
//  Created by nxa-tankeke on 16/11/15.
//  Copyright © 2016年 com.yuan. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

typedef enum {
    userCenterUrl,
    userCityUrl,//轻量级用户9090
    userZoneUrl //功能用户 9290
} UrlType;

/**
 *  网络请求成功回调block
 *
 *  @param result 返回data
 *  @param code   返回码
 *  @param msg    返回信息
 */
typedef void (^CallbackDidFinishWithResultHandler) (id result, NSString *code, NSString *msg);

/**
 *  网络请求失败回调block
 *
 *  @param code 返回码
 *  @param msg  返回信息
 */
typedef void (^CallbackDidFailWithErrorHandler) (NSString * code, NSString * msg);


@interface JYTHttpClient : NSObject

/**********************************属性**********************************************/
@property (nonatomic, strong) CallbackDidFailWithErrorHandler errorCallbackHandler;
@property (nonatomic, strong) CallbackDidFinishWithResultHandler finishCallbackHandler;

/**
 *  网络请求基本url
 */
@property (nonatomic, strong) NSString *baseUrl;
@property (nonatomic, strong) NSString *cityUrl;
@property (nonatomic, strong) NSString *zoneUrl;
@property (nonatomic, assign) UrlType urlType;

/**********************************方法**********************************************/

/**
 *  httpclient 单例对象获取方法
 *
 *  @return httpclient对象
 */
+ (JYTHttpClient *)sharedInstance;


/**
 *  网络请求post
 *
 *  @param path  请求的url
 *  @param param 请求参数
 */
- (void) post:(NSString *)path withParam:(NSDictionary *) param;

/**
 *  检测当前是否有网络
 *
 */
- (void)currentNetworkStatusWithHandler:(void(^)(NSString *status, BOOL success))handler;

/**
 *  字典转json
 *
 *  @param param 请求参数
 *
 *  @return 字符串
 */
- (NSString *) converseToJson:(id) param;

/**
 *  json字符串转字典转
 *
 *  @param jsonString 请求参数
 *
 *  @return 字典
 */
- (id)dictionaryWithJsonString:(NSString *)jsonString;



-(NSString *) md5_base64:(NSString *)str;

@end
